home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 721 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  50 lines

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: printf() format extensions - looking for beta testers...
  5. Date: 10 Apr 1996 10:54:39 -0500
  6. Organization: Usenet Fact Police (Undercover)
  7. Approved: seebs
  8. Message-ID: <4kgljv$l2p@solutions.solon.com>
  9. Reply-To: seebs@solon.com
  10. NNTP-Posting-Host: solutions.solon.com
  11.  
  12. I have submitted a cover sheet to the C9X people for a new feature of printf,
  13. which would provide user-defined format specifiers, and similar "features".
  14.  
  15. I have the beginnings of a real implementation to play with, and I am looking
  16. for beta testers.
  17.  
  18. The basic idea of the proposed feature is that users would be able to install
  19. new formats; for instance, the user would
  20. do something like
  21.     int bangcvt(va_list *ap, char *s, int len, fmtspec *f) {
  22.         strncpy(s, strerror(errno), len);
  23.         s[len - 1] = '\0';
  24.         return strlen(s);
  25.     }
  26.  
  27.     main() {
  28.         format('!', bangcvt);
  29.  
  30.         /* do something which can generate an error */
  31.         fprintf(stderr, "%s: %!\n", "open failed");
  32.     }
  33. ...
  34.  
  35. (This example may not be correct, but is expected to give the idea of
  36. intended usage.)
  37.  
  38. I would appreciate comments, suggestions, or volunteers.  I hope to have
  39. a tested and portable implementation available "real soon now".
  40.  
  41. (Obviously, before any adoption occurs, it will be done with functions
  42. not named printf/fprintf/etc.)
  43.  
  44. -s
  45. -- 
  46. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  47. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  48. FUCK the communications decency act.  Goddamned government.  [literally.]
  49. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  50.